#cs ----------------------------------------------------------------------------
	
	$Author: bjoern.kaiser $
	$LastChangedDate: 2008-05-02 13:09:41 +0000 (Fri, 02 May 2008) $
	
	Script Function:
	Change sysprepped XP HAL
	
#ce ----------------------------------------------------------------------------

#include-once
;~ #include ".\7z.au3"

Func _hal_Swap($intNumCpus, $strImageHal, $strTarget = "C:")
;~ 	$sDetectedHal = StringUpper(RegRead("HKLM\SYSTEM\CurrentControlSet\Enum\Root\ACPI_HAL\0000", "HardwareID"))
;~ 	$intNumCpus = EnvGet("NUMBER_OF_PROCESSORS")
;~ 	$strImageHal = "ACPIAPIC_MP"
;~ 	$sSysprepInf = "C:\sysprep\sysprep.inf"
;~ 	$sSpVersion = "2"
;~ 	$Z = "Z:"
;~ 	$sTgtDrive = "C:"
;~ 	$iDebug = 1
	Local $strNewHal
	
	If $intNumCpus = 1 Then
		$strNewHal = $gStrDetectedHal & "_UP"
	Else
		$strNewHal = $gStrDetectedHal & "_MP"
	EndIf
	_log("I","Image HAL: " & $strImageHal)
	_log("I","New HAL: " & $strNewHal)
;~ If $strNewHal = $strImageHal Then Exit

	_log("D", "Detected HAL:" & @CRLF & $strNewHal)

	Select
;~ 	Case $strNewHal = $strImageHal
;~ 		Exit
		Case StringRight($strNewHal, 3) = "_UP"
;~ 		MsgBox(0,"HAL","_UP: " & $strNewHal & @CRLF)
			_hal_UpHal($strNewHal, $strTarget)
		Case StringRight($strNewHal, 3) = "_MP"
;~ 		MsgBox(0,"HAL","_MP: " & $strNewHal & @CRLF)
			_hal_MpHal($strNewHal, $strTarget)
	EndSelect

EndFunc   ;==>_hal_Swap

#CS
	Prepare for UPHal
#CE

Func _hal_UpHal($strHal, $strTarget)
	Select
		Case $strHal = "ACPIPIC_UP"
			_7z_HalUnpack($strTarget, "halacpi.dll", "hal.dll")
			_7z_HalUnpack($strTarget, "ntkrnlpa.exe")
			_7z_HalUnpack($strTarget, "ntoskrnl.exe")
		Case $strHal = "ACPIAPIC_UP"
			_7z_HalUnpack($strTarget, "halaacpi.dll", "hal.dll")
			_7z_HalUnpack($strTarget, "ntkrnlpa.exe")
			_7z_HalUnpack($strTarget, "ntoskrnl.exe")
	EndSelect
	If Not $gBinTest Then
		IniDelete($gStrSysprepInf, "Unattended", "UpdateHAL")
		IniWrite($gStrSysprepInf, "Unattended", "UpdateUPHAL", $strHal & ",%WINDIR%\Inf\Hal.inf")
	EndIf
EndFunc   ;==>_hal_UpHal

#CS
	Prepare for MPHal
#CE

Func _hal_MpHal($strHal, $strTarget)
	Select
		Case $strHal = "ACPIAPIC_MP"
			_7z_HalUnpack($strTarget, "halmacpi.dll", "hal.dll")
			_7z_HalUnpack($strTarget, "ntkrpamp.exe", "ntkrnlpa.exe")
			_7z_HalUnpack($strTarget, "ntkrnlmp.exe", "ntoskrnl.exe")
	EndSelect
	If Not $gBinTest Then
		IniDelete($gStrSysprepInf, "Unattended", "UpdateUPHAL")
		IniWrite($gStrSysprepInf, "Unattended", "UpdateHAL", $strHal & ",%WINDIR%\Inf\Hal.inf")
	EndIf
EndFunc   ;==>_hal_MpHal